//
//  HomeFamilyCell.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/27.
//

#import "HomeFamilyCell.h"

@interface HomeFamilyCell()
@property (nonatomic,strong) UIImageView * iconView;
@property (nonatomic,strong) UILabel * nameLabel;
@end

@implementation HomeFamilyCell

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setSubViewLayout];
    }
    return self;
}

-(void)setSelected:(BOOL)selected{
    
    if (selected) {
        [self.iconView setCornerRadius:25 * FMScaleX borderWidth:2 borderColor:RDRGB(0xAD7D62)];
        self.nameLabel.textColor = RDRGB(0xAD7D62 );
    }else{
        
        [self.iconView setCornerRadius:25 * FMScaleX borderWidth:0 borderColor:UIColor.clearColor];
        self.nameLabel.textColor = RDRGB(0x666666 );
    }
    
}

-(void)setSubViewLayout{
    
    [self addSubview:self.iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@0);
        make.size.mas_offset(50 * FMScaleX);
        make.centerX.equalTo(@0);
    }];
    [self addSubview:self.nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(@0);
    }];
    
}

-(void)setIndex:(NSInteger)index{
    
    switch (index) {
        case 0:
            self.nameLabel.text = @"自己";
            self.iconView.image = [UIImage imageNamed:@"Common_family_zj"];
            break;
        case 1:
            self.nameLabel.text = @"爸爸";
            self.iconView.image = [UIImage imageNamed:@"Common_family_bb"];

            break;
        case 2:
            self.nameLabel.text = @"妈妈";
            self.iconView.image = [UIImage imageNamed:@"Common_family_mm"];

            break;
        case 3:
            self.nameLabel.text = @"老婆";
            self.iconView.image = [UIImage imageNamed:@"Common_family_lp"];

            break;
        case 4:
            self.nameLabel.text = @"儿子";
            self.iconView.image = [UIImage imageNamed:@"Common_family_ez"];

            break;
        default:
            break;
    }
    
}

-(UIImageView *)iconView{
    
    if (!_iconView) {
        _iconView = [[UIImageView alloc]init];
        [_iconView setCornerRadius:25 * FMScaleX];
        _iconView.backgroundColor = RDRGB(0xEBE3DA);
    }
    return _iconView;
}
-(UILabel *)nameLabel{
    
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = Regular(14);
        _nameLabel.textColor = RDRGB(0x666666);
        _nameLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _nameLabel;
}
@end
